package net.uhuijia.shop.info.controller;

import net.uhuijia.shop.info.persistence.model.Shop;
import net.uhuijia.shop.info.persistence.model.ShopExample;
import net.uhuijia.user.usermall.persistence.model.UserMall;
import net.uhuijia.vo.ResultMapVo;
import net.uhuijia.vo.ReturnListVo;
import net.uhuijia.vo.shop.ShopDetailVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import net.uhuijia.appbase.controller.BaseController;
import net.uhuijia.shop.info.service.ShopService;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;


@Controller
@RequestMapping(value="/info")
public class ShopController
     extends BaseController<ShopService,Shop,ShopExample> {
    @Autowired
    private ShopService shopService;

    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    @ResponseBody
    public ResultMapVo detail(HttpServletRequest request,String shopId) {
        if(StringUtils.isEmpty(shopId))
            throw new IllegalArgumentException();

        return ResultMapVo.ok();
    }

    /**
     * @Author xzj
     * @Description //商家入驻接口
     * @Date  2018/10/7
     * @Param
     * @return
     **/
    @RequestMapping(value = "/join", method = RequestMethod.GET)
    @ResponseBody
    public ResultMapVo<Shop> join(HttpServletRequest request,String shopId,String realName,String phone,String code,String idCardFrontImg,String idCardBackImg) {
        if(StringUtils.isNoneBlank(realName,phone,code,idCardFrontImg,idCardBackImg))
            throw  new IllegalArgumentException();
        //TODO 效验验证码是否正确
        UserMall userMall = this.getUserMallByTokenAndDevice();
        Shop shop = this.shopService.joinShop(userMall,shopId,realName,phone,idCardFrontImg,idCardBackImg);
        return ResultMapVo.ok(shop);
    }



}